﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace 桌面视频录制
{
    [Serializable]
    public class DrawCube: DrawRectangle
    {
        public DrawCube(Point point)
            : base(point) { }
        public override void Draw(Graphics g)
        {
            if (width <= 0 || height <= 0)
                return;
            Pen pen = new Pen(this.penColor, this.penWidth);
            PointF p1 = GetMiddlePoint(leftUpPoint, GetMiddlePoint(leftUpPoint, leftDownPoint));
            PointF p2 = GetMiddlePoint(leftUpPoint, GetMiddlePoint(leftUpPoint, rightUpPoint));
            PointF p5 = GetMiddlePoint(rightDownPoint, GetMiddlePoint(rightDownPoint, rightUpPoint));
            PointF temp = GetMiddlePoint(rightUpPoint, GetMiddlePoint(rightUpPoint, rightDownPoint));
            PointF p3 = GetMiddlePoint(temp, GetMiddlePoint(temp, p1));
            PointF p4 = GetMiddlePoint(rightDownPoint, GetMiddlePoint(rightDownPoint, leftDownPoint));
            g.DrawLines(pen, new PointF[] { p1, p2, rightUpPoint, p3, p1 });
            g.DrawLines(pen, new PointF[] { p1, leftDownPoint, p4, p3 });
            g.DrawLines(pen, new PointF[] { p4, p5, rightUpPoint });
            PointF t1 = GetMiddlePoint(leftDownPoint, GetMiddlePoint(leftDownPoint, leftUpPoint));
            PointF t2 = GetMiddlePoint(t1, GetMiddlePoint(t1, p5));
            pen.DashStyle = DashStyle.Dot;
            pen.DashPattern = new float[] { 5.0f, 5.0f };
            g.DrawLine(pen, p2, t2);
            g.DrawLine(pen, leftDownPoint, t2);
            g.DrawLine(pen, p5, t2);
            pen.Dispose();
        }
        public override string ToString()
        {
            string printMsg = "[立方体(" + this.leftUpPoint.X + "," + this.leftUpPoint.Y + ")]->[ID:" + this.Id + "]";
            return printMsg;
        }
        public override string GetDrawObjectMsg()
        {
            string drawObjectMsg = "立方体->起始位置(" + this.leftUpPoint.X + "," + this.leftUpPoint.Y + "),宽高(" + this.width + "," + this.height + "),偏移角度:" + ((int)(angle * 180 / Math.PI)) + "°";
            return drawObjectMsg;
        }
    }
}
